
#include "CInput.h"

CInputManager::CInputManager()
{
}

CInputManager::~CInputManager()
{

}

void CInputManager::_BuildEvent(Input_EventType type, SDLKey key, Uint16 x, Uint16 y)
{
	Input_Event event;
	event.type = type;
	event.key = key;
	event.x = x;
	event.y = y;
	m_Events.push_back(event);

	m_keystate = SDL_GetKeyState(NULL);

	//if (type && (INPUT_MOUSEMOVE | INPUT_LBUTTONDOWN | INPUT_RBUTTONDOWN | INPUT_LBUTTONUP | INPUT_RBUTTONUP))
	//{
	//	m_Xpos = x;
	//	m_Ypos = y;
	//	if (type == INPUT_LBUTTONDOWN)
	//		m_LButtonDown = true;
	//	else if (type == INPUT_LBUTTONUP)
	//		m_LButtonDown = false;
	//	else if (type == INPUT_RBUTTONDOWN)
	//		m_RButtonDown = true;
	//	else if (type == INPUT_RBUTTONUP)
	//		m_RButtonDown = false;
	//}
	//else if (type && (INPUT_KEYDOWN | INPUT_KEYUP))
	//{
	//	m_Key = key;
	//}
}

void CInputManager::_ClearEvent()
{
	m_Events.clear();
}

void CInputManager::GetMousePos(int* x, int* y)
{
	SDL_GetMouseState(x, y);
}

void CInputManager::SetMousePos(Uint16 x, Uint16 y)
{
	SDL_WarpMouse(x, y);
}

bool CInputManager::GetKeyState(SDLKey key)
{
	if (m_keystate[key])
		return true;
	else
		return false;
}